<#assign ctx=request.contextPath />
<!DOCTYPE html>
<html>
  <head>
    <title>${Func.getMainCompanyJc()?if_exists}管理平台-完工</title>
    <link rel="shortcut icon" type="image/x-icon" href="${ctx}/assets/img/ezu.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="${ctx}/assets/css/bootstrap.css">
    <link rel="stylesheet" href="${ctx}/assets/css/scojs.css">
    <link rel="stylesheet" href="${ctx}/assets/css/sco.message.css">
	<link rel="stylesheet" href="${ctx}/assets/css/form.css">
	<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
	<style>
		.form-group {
			margin-bottom: 2px;
		}
		hr{
			margin-top: 5px;
 			margin-bottom: 15px;
		}
	</style>
  </head>
  <body>
  	<div class="container-fluid">
  		<div class="row" style="margin-top:20px;">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						完工
				    </div>
				    <div class="panel-body">
	    				<form id="submit_form" action="#" class="form-horizontal" method="post">
			               	<input type="hidden" id="orderId"  value="${order.id}" />
			               	<input type="hidden" id="prePayTypeDetail"  value="${order.prePayTypeDetail?if_exists}" />
			               	<input type="hidden" id="companyId" value="${order.companyId}" />
			               	<input type="hidden" id="couponId" value="${order.couponId?if_exists}" />
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label">客户名称：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.passengerName?if_exists}<#if passenger??> (余额：${passenger.drawMoney}元)</#if></p>
			                    </div>
			                    <label class="col-sm-2 control-label">客户电话：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.passengerPhone?if_exists}</p>
			                    </div>
			                </div>
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label">预约地：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.startAddress?if_exists}</p>
			                    </div>
			                    <label class="col-sm-2 control-label">预约时间：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static">${order.serverTime?string("yyyy-MM-dd HH:mm")}</p>
			                    </div>
			                 </div>
			                 <div class="form-group">
			                    <label class="col-sm-2 control-label"><em>*</em>等候分钟：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="midwayWait" name="midwayWait" type="number" min="0" value="0" required/>
			                    </div>
			                    <label class="col-sm-2 control-label"><em>*</em>行驶分钟：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="runTime" name="runTime" type="number" min="0" value="0" required/>
			                    </div>
			                 </div>
			                
			                 <div class="form-group">
			                    
			                 </div>
			                
			                 <div class="form-group">
			                    <label class="col-sm-2 control-label"><em>*</em>行驶里程：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="mileage" name="mileage" type="text" min="0" value="0" required/>
			                    </div>
			                    <label class="col-sm-2 control-label"><em>*</em>完工时间：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="finishTime" name="finishTime" type="text" value="${.now?string("yyyy-MM-dd HH:mm")}" required/>
			                    </div>
			                  </div>
			                
		                  <div class="form-group">
	                          <label class="col-sm-2 control-label"><em>*</em>结算类型：</label>
		                      <div class="col-sm-4">
		                    	<select class="form-control" id="payType" name="payType" required>
						  			<option value="">--请选择--</option>
						  			<option value="cash">代付</option>
						  			<option value="sign">签单</option>
						  			<option value="balance">余额</option>
						  		</select>
		                      </div>
		                      <label class="col-sm-2 control-label">目的地：</label>
		                      <div class="col-sm-4">
		                    	<input class="form-control" id="endAddress" name="toPlace" type="text" min="0" value="${order.endAddress?if_exists}"/>
	                   	      </div>
		                   </div>
			               <div class="form-group">
			               	   <label class="col-sm-2 control-label">过路费：</label>
		                       <div class="col-sm-4">
		                           <input class="form-control" id="guoluMoney"  type="text" min="0" value="${order.guoluMoney!0.0}"/>
	                   	       </div>
		                   </div>
			               <div class="form-group">
			                    <label class="col-sm-2 control-label"><em>*</em>实收金额：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="realPay" name="realPay" type="text" min="0" required/>
			                    </div>
			                    <label class="col-sm-2 control-label">报销金额：</label>
			                    <div class="col-sm-4">
			                    	<input class="form-control" id="baoxiaoMoney" name="baoxiaoMoney" type="text" min="0"/>
			                    </div>
			                </div>
			                	
			             	<div class="form-group">
			                    <label class="col-sm-2 control-label">订单备注：</label>
			                    <div class="col-sm-4">
			                    	<textarea class="form-control" cols="20" id="employMemo" name="employMemo" rows="2">${order.employMemo?if_exists}</textarea>
			                    </div>
			                    <label class="col-sm-2 control-label">报销说明：</label>
			                    <div class="col-sm-4">
			                    	<textarea class="form-control" cols="20" id="baoxiaoMemo" name="baoxiaoMemo" rows="2"></textarea>
			                    </div>
			                </div>
			                
			                
			                
			                <div class="form-group">
			                    <label class="col-sm-2 control-label">操作人：</label>
			                    <div class="col-sm-4">
			                    	<p class="form-control-static"><@shiro.principal property='username'/></p>
			                    </div>
			                </div>
			       
			                
			                <div class="form-group">
			                	<div class="col-sm-2">
			                	</div>
			                	<div class="col-sm-10">
			                		<input id="submit_button" type="submit" class="btn btn-primary" value="确认提交">
			                		<input type="button" class="btn btn-default" onclick="window.close();" value="关闭">
			                	</div>
				            </div>
				            
				       
				            
						</form>
	        		</div>
				</div>
			</div>
		</div>
  	</div>
  	<div class="container" style="margin-top:10px;margin-left:0px;">
    	
    	<div class="row">
			
		</div>
   
	</div>
	<script type="text/javascript" language="javascript">window.daijia = {ctx : '${ctx}'};</script>
    <script src="${ctx}/assets/js/jquery-1.11.0.min.js"></script>
    <script src="${ctx}/assets/js/bootstrap.min.js"></script>
    <script src="${ctx}/assets/js/sco.modal.js"></script>
    <script src="${ctx}/assets/js/sco.message.js"></script>
    <script src="${ctx}/assets/js/sco.confirm.js"></script>
    <script src="${ctx}/assets/js/bootstrap-datetimepicker.min.js"></script>
	<script src="${ctx}/assets/js/bootstrap-datetimepicker.zh-CN.js"></script>
	<script type="text/javascript">
	
		$(document).ready(function(){
			
			$("#finishTime").datetimepicker({ format: 'yyyy-mm-dd HH:ii', language: 'zh-CN', pickDate: true, pickTime: true, inputMask: false, autoclose: true });
		
			$("#submit_form").submit(function(){
				
				var reg=/^(-?\d+)(.[0-9]{0,2})?$/;
				
				var mileage=$("#mileage").val();
				if(!reg.test(mileage)){
			       $.scojs_message('请输入正确的里程', $.scojs_message.TYPE_ERROR);
			       return false;
			    }
		    
				var realPay=$("#realPay").val();
				if(!reg.test(realPay)){
			       $.scojs_message('请输入正确的实收金额', $.scojs_message.TYPE_ERROR);
			       return false;
			    }
			    
			    var baoxiaoMoney=$("#baoxiaoMoney").val();
			    if(baoxiaoMoney.length>0){
			    	if(!reg.test(baoxiaoMoney)){
				       $.scojs_message('请输入正确的报销金额', $.scojs_message.TYPE_ERROR);
				       return false;
				    }
			    }
				
				issubmit=true;
				
				//禁用按钮
				$("#submit_button").attr("disabled",true);
				$("#submit_button").val("提交中...");
				$.post("${ctx}/zhuanche/completeOrder",{
			             'orderId':$("#orderId").val(),'midwayWait':$("#midwayWait").val(),'runTime':$("#runTime").val(),'mileage':$("#mileage").val(),
			             'finishTime':$("#finishTime").val(),'payType':$("#payType").val(),'endAddress':$("#endAddress").val(),'realPay':$("#realPay").val(),
			             'baoxiaoMoney':$("#baoxiaoMoney").val(),'employMemo':$("#employMemo").val(),'baoxiaoMemo':$("#baoxiaoMemo").val(),
			             'prePayTypeDetail':$("#prePayTypeDetail").val(),'guoluMoney':$("#guoluMoney").val(),'couponId':$("#couponId").val(),'companyId':$("#companyId").val()},
			             function(data){
				             if (data.success) {
				            	 $.scojs_message("操作成功", $.scojs_message.TYPE_OK);
								 setTimeout(function(){
									window.opener.location.reload(true);
					    			window.close();
					    		 }, 1000);
				             } else {
				             	 $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
				             	 $("#submit_button").removeAttr("disabled");
				             	 $("#submit_button").val("确认提交");
				             }
			       		 },'json');
						         
				return false;
			});
			
		
		});
		
		<!--关闭浏览器 -->  
		var issubmit = false;
		window.onbeforeunload = function () {
			if(!issubmit){
				return ("您确认要离开该页面吗?");
			}
		}  

	</script>
	
  </body>
</html>